package dao

import (
	"context"
	"go-mall/model"
	"gorm.io/gorm"
)

type NotificationDao struct {
	*gorm.DB
}

func NewNotificationDao(ctx context.Context) *NotificationDao {
	return &NotificationDao{NewDBCliet(ctx)}
}

// 获取全部分类
func (dao *NotificationDao) ListNotification(page model.BasePage) (notifications []*model.Notification, err error) {
	err = dao.DB.Model(&model.Notification{}).Offset((page.PageNum - 1) * (page.PageSize)).
		Limit(page.PageSize).Find(&notifications).Error
	return notifications, err
}
